import 'package:flutter/material.dart';

class PullUpToRefreshAnimation extends StatefulWidget {
  @override
  _PullUpToRefreshAnimationState createState() => _PullUpToRefreshAnimationState();
}

class _PullUpToRefreshAnimationState extends State<PullUpToRefreshAnimation> with SingleTickerProviderStateMixin {
  AnimationController _animation;

  @override
  void initState() {
    _animation = AnimationController(vsync: this, duration: Duration(milliseconds: 200))
      ..repeat();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      height: 40,
      child: Row(
        children: [
          Spacer(),
          AnimatedBuilder(
            animation: _animation,
            builder: (BuildContext context, Widget child) {
              return bottomLoadingAnimationAssets[
              (_animation.value * 5).round()];
            },
          ),
          const Text("   加载更多"),
          Spacer(),
        ],
      ),
    );
  }

  @override
  void dispose() {
    _animation.dispose();
    super.dispose();
  }
}
List<Image> bottomLoadingAnimationAssets = List.generate(6, (index) {
  index = index + 1;
  var img = index.toString().padLeft(2, '0');
  return Image.asset(
      "assets/bottom_loading_anim/legwork_wm_ptr_anim_$img.webp");
});